﻿/* Includes: */
#include "GraphEngine.h"

/** Глобальная переменная объекта графической системы игры. */
GrEngine g_graphEngine;

CCScene* GrEngine::getMainMenuScene()
{
    CCScene* scene = CCScene::node();
    CCLayer* layer = new GrMainMenuLayer();
    layer->autorelease();

    scene->addChild( layer );
    return scene;
}

void GrEngine::showMainMenu()
{
    CCDirector::sharedDirector()->replaceScene( 
                    makeCCSceneTransaction( SCENE_TRANSITION_DURATION, 
                                          getMainMenuScene() ) );
}

CCScene* GrEngine::getSplashScreenCCScene()
{
    CCScene* scene = CCScene::node();
    CCLayer* layer = new GrSplashScreenLayer();
    layer->autorelease();

    scene->addChild( layer );
    return scene;
}

GrSceneAbstract* GrEngine::getLoadingScreenScene()
{
    GrSceneAbstract* scene = new GrLoadingScreenScene();
    return scene;
}

void GrEngine::showLoadingScreen()
{
    GrSceneAbstract* scene = getLoadingScreenScene();
    if ( scene ) {
        scene->runScene();
    }
}

GrSceneAbstract* GrEngine::getRecordsScreenScene()
{
    GrSceneAbstract* scene = new GrRecordsScreenScene( true );
    return scene;
}

void GrEngine::showRecordsScreen()
{
    GrSceneAbstract* scene = getRecordsScreenScene();
    if ( scene ) {
        scene->runScene();
    }
}

GrSceneAbstract* GrEngine::getSettingsScreenScene()
{
    GrSceneAbstract* scene = new GrSettingsScreenScene( true );
    return scene;
}

void GrEngine::showSettingsScreen()
{
    GrSceneAbstract* scene = getSettingsScreenScene();
    if ( scene ) {
        scene->runScene();
    }
}

CCScene* GrEngine::makeCCSceneTransaction( ccTime time, CCScene* scene )
{
    CCDirector::sharedDirector()->setDepthTest( false );
    return CCTransitionFade::transitionWithDuration( SCENE_TRANSITION_DURATION, scene );
}

void GrEngine::showGameScene()
{
    GrSceneAbstract* scene = new GrGameScene( true );
    if ( scene ) {
        scene->runScene();
    }
}
